/*
 * IntegrationClient.java   0.0.1    Dec 5, 2009
 * 
 * Copyright (c) 2009 mentalsmash.org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * The use of the Apache License does not indicate that this project is
 * affiliated with the Apache Software Foundation.
 */
package org.mentalsmash.tazio.transparency.clientServerInteraction.client.test;

import org.mentalsmash.tazio.impl.WRMTazioStarter;
import org.mentalsmash.tazio.transactions.Share;
import org.mentalsmash.tazio.transactions.Transaction;
import org.mentalsmash.tazio.transactions.UserTransactionManager;
import org.mentalsmash.tazio.transactions.mock.ImagePosition;
import org.mentalsmash.tazio.transactions.mock.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @version 0.0.1 Dec 5, 2009
 * @author Andrea Sorbini <as@mentalsmash.org>
 *
 */
public class IntegrationClient {

    private final static Logger log = LoggerFactory.getLogger(IntegrationClient.class);
    
    public static void main(String[] args) throws Exception{
	
	log.debug("Initializing WRM");
	WRMTazioStarter wrmStarter = new WRMTazioStarter(false);
	wrmStarter.initTazio();
	
	Thread.sleep(1000);
//	LocalDispatchingLayerProxy serverProxy = (LocalDispatchingLayerProxy) rmStarter.getRILInvoker().getDispatchingLayerProxy();
//	LocalDispatchingLayerProxy clientProxy = (LocalDispatchingLayerProxy) wrmStarter.getRILInvoker().getDispatchingLayerProxy();
//	
//	clientProxy.setInGroup(false);
//	serverProxy.connectTo(clientProxy);
//	
	
	Share theShare = wrmStarter.getShare();
	UserTransactionManager tm = wrmStarter.getTransactionManager();
	
	
	Transaction tx = tm.begin();
	ImagePosition i1 = theShare.createObject(ImagePosition.class);
	User u1 = theShare.createObject(User.class);
	tx.commit();
	
	tx = tm.begin();
	i1.setX(20);
	u1.setUsername("John");
	tx.commit();
	
	tx = tm.begin();
	tx.commit();
	
	System.out.println(" _" + i1.getX() + "_ "+u1.getUsername()+" was here ");

	
    }
        
}
